﻿@model List<Mondial2014.Controllers.GameGamblesController.GameGambleViewModel>

@{
    ViewBag.Title = "הימורים";
}

<h2>עידכון הימורים עבור @Html.DisplayFor(model => model.First().GamblerName)</h2>

@Html.ActionLink("חזרה לרשימת משתתפים", "Index", "Gamblers")
<br/><br />

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        
        <div class="form-group">
            <input type="submit" value="שמור" class="btn btn-default" />
        </div>

        @for (var groupNumber = 0; groupNumber < 8; groupNumber++)
        {
            <h4>בית @(groupNumber + 1)</h4>

            <table class="table">
                <tr>
                    <th>
                        משחק מספר
                    </th>
                    <th>
                        תאריך
                    </th>
                    <th>
                        קבוצה 1
                    </th>
                    <th>
                        קבוצה 2
                    </th>
                    <th>
                        הימור
                    </th>
                </tr>

                @for (var gameNumber = (6*groupNumber); gameNumber < (6*groupNumber + 6); gameNumber++)
                {
                    <tr>
                        <td>
                            @Html.TextBox("gameGambleViewModels[" + @gameNumber + "].GameNumber", Model[gameNumber].GameNumber, new { @readonly = "readonly", @style = "display:none" })
                            @Html.TextBox("gameGambleViewModels[" + @gameNumber + "].GamblerId", Model[gameNumber].GamblerId, new { @readonly = "readonly", @style = "display:none" })

                            @Html.DisplayFor(modelItem => Model[gameNumber].GameNumber)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => Model[gameNumber].Date)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => Model[gameNumber].Team1)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => Model[gameNumber].Team2)
                        </td>
                        <td>
                            @{ var result = (int)Model[gameNumber].Result; }

                            @Html.DropDownList("gameGambleViewModels[" + @gameNumber + "].Result", new[] { new SelectListItem { Text = "ריק", Value = "0", Selected = (result == 0) }, new SelectListItem { Text = "1", Value = "1", Selected = (result == 1) }, new SelectListItem { Text = "2", Value = "2", Selected = (result == 2) }, new SelectListItem { Text = "X", Value = "3", Selected = (result == 3) } })
                        </td>
                    </tr>
                }

            </table>
        }
        
        <div class="form-group">
            <input type="submit" value="שמור" class="btn btn-default" />
        </div>

    </div>
}
<div>
    <br />
    @Html.ActionLink("חזרה לרשימת משתתפים", "Index", "Gamblers")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

